package com.jms.mybatis.plus.creator;

import com.jms.framework.beans.BeanDefinition;
import com.jms.framework.beans.annotation.Component;
import com.jms.framework.beans.creator.SingletonBeanFactoryCreator;
import com.jms.framework.beans.factory.ObjectFactory;
import com.jms.framework.context.ApplicationContext;
import com.jms.mybatis.plus.beans.MapperBeanDefinition;
import com.jms.mybatis.plus.beans.factory.MapperBeanFactory;

@Component
public class MapperSingletonBeanFactoryCreator extends SingletonBeanFactoryCreator {
    public MapperSingletonBeanFactoryCreator() {
        super(100);
    }

    @Override
    public ObjectFactory<?> create(BeanDefinition beanDefinition, ApplicationContext applicationContext) {
        if (MapperBeanDefinition.class.equals(beanDefinition.getClass())) {
            return new MapperBeanFactory((MapperBeanDefinition) beanDefinition);
        }
        return null;
    }
}
